package com.oa.business.org.dto;


import com.oa.common.DomainDto;
import com.oa.framework.org.domain.Duty;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@Setter
public class DutyDto implements DomainDto<Duty> {

    private Long dutyId;

    private String dutyCode;

    private String dutyName;

    private Long postId;

    private String description;

    private List<PermissionDto> permissions;

    @Override
    public Duty transform() {
        Duty duty = new Duty();
        duty.setDutyId(dutyId);
        duty.setDutyCode(dutyCode);
        duty.setDutyName(dutyName);
        duty.setPostId(postId);
        duty.setDescription(description);
        if(permissions != null){
            duty.setPermissions(permissions.stream().map(v -> v.transform()).collect(Collectors.toList()));
        }
        return duty;
    }
}
